﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.Services.Client;
using System.Reflection;
using System.Web.UI.Design;
using System.Collections;
using System.Windows.Forms;
using System.Data;
using System.Drawing;

namespace ODataSource
{
    //[DefaultProperty("Text")]
    [ToolboxData("<{0}:ODataSource runat=server></{0}:ODataSource>")]
    [ToolboxBitmap(typeof(ResourceFinder), "ODataSource.ODataSource.bmp")]
    [Designer(typeof(ODataSourceDesigner))]
    public class ODataSource : ContextDataSource
    {

        protected override QueryableDataSourceView CreateQueryableView()
        {
            return new ODataSourceQueryableView(this, "", this.Context, this);
        }

        [TypeConverter(typeof(EntitySetPropertyEditor))]
        public string EntitySet 
        { 
            get{ return EntitySetName;}
            set 
            {
                EntitySetName = value;
                //RaiseDataSourceChangedEvent(new EventArgs());
            }
        }

        [TypeConverter(typeof(ContextPropertyEditor))]
        public override string ContextTypeName
        {
            get
            {
                return base.ContextTypeName;
            }
            set
            {
                base.ContextTypeName = value;
            }
        }

        [Browsable(false)]
        public override string EntityTypeName
        {
            get
            {
                return base.EntityTypeName;
            }
            set
            {
                base.EntityTypeName = value;
            }
        }

        internal ODataSourceQueryableView View
        {
            get { return this.GetView("") as ODataSourceQueryableView; }
        }

        public bool EnableInsert { get; set; }
        public bool EnableUpdate { get; set; }
        public bool EnableDelete { get; set; }

    }

}
